package ru.arriah.servicedesk.ejb;

import java.util.Collection;
import java.util.Date;

import javax.ejb.EJBLocalObject;

import ru.arriah.servicedesk.bean.IntWrapper;
import ru.arriah.servicedesk.bean.MainReportBean;
import ru.arriah.servicedesk.bean.ReportBean;
import ru.arriah.servicedesk.bean.RequestBean;
import ru.arriah.servicedesk.bean.RequestHistoryBean;
import ru.arriah.servicedesk.bean.RequestPriorityBean;
import ru.arriah.servicedesk.bean.RequestStatusBean;
import ru.arriah.servicedesk.bean.RequestTypeBean;
import ru.arriah.servicedesk.bean.TaskBean;
import ru.arriah.servicedesk.bean.TaskStatusBean;

public interface RequestManagerLocalObject extends EJBLocalObject {
  public RequestBean selectRequest(int requestId);
  public RequestBean selectRequestByTaskId(int taskId);
  public RequestBean selectRequestDetails(int requestId);
  public Collection<RequestBean> selectRequestsByStatus(int statusId);
  
  public Collection<RequestBean> selectRequests();
  public Collection<RequestBean> selectRequests(String orderBy, String order);
  
  public Collection<RequestBean> selectRequests(
    String orderBy,
    String order,
    int page,
    int itemsPerPage,
    IntWrapper records
  );
  
  public Collection<RequestBean> selectRequests(
     String orderBy,
     String order,
     String status
  );
  
  public Collection<RequestBean> selectRequests(
    String orderBy,
    String order,
    int page,
    int itemsPerPage,
    IntWrapper records,
    String status
  );
  
  public boolean addRequest(RequestBean requestBean, int userId);
  public boolean commitRequestByDispatcher(RequestBean requestBean);
  
  public boolean updateRequest(RequestBean requestBean, int userId);
  public boolean updateRequestByLeadExecutor(
    RequestBean requestBean, int userId
  );
    
  public Collection<RequestTypeBean> selectRequestTypes();
  
  public boolean setRequestStatus(int requestId, int statusId, int userId);
  public boolean setTaskStatus(int taskId, int statusId, int userId);
  
  public Collection<RequestBean> selectRequestsByGroup(int groupId);  
  public TaskBean selectTask(int taskId);
  public boolean addTask(TaskBean taskBean);
  public boolean updateTask(TaskBean taskBean);
  public Collection<TaskStatusBean> selectTaskStatus();
  public Collection<RequestBean> selectNewRequestsByLeadExecutor(int leadExecutorId);
  
  public Collection<TaskBean> selectTasksByRequest(
    int requestId
  );
  
  public Collection<TaskBean> selectTasksByRequest(
    int requestId,
    String orderBy,
    String order
  );
  
  public Collection<RequestBean> selectBurningRequestsByLeadExecutor(
    int leadExecutorId
  );
  
  public boolean setRequestReport(int requestId, String report);
  
  public Collection<TaskBean> selectTasksByExecutor(
     int executorId, 
     String orderBy, 
     String order,
     int page,
     int itemsPerPage,
     IntWrapper records
  );
  public Collection<TaskBean> selectTasksByExecutor(int executorId, String orderBy, String order);
  public Collection<TaskBean> selectTasksByExecutor(int executorId);
  
  public boolean setTaskReport(int taskId, String report);
  
  public Collection<RequestBean> selectRequestsByClient(int clientId, String orderBy, String order);
  public Collection<RequestBean> selectRequestsByClient(int clientId);  
  
  public Collection<RequestBean> selectRequestsByClient(
    int clientId,
    String orderBy, 
    String order,
    int page,
    int itemsPerPage,
    IntWrapper records
  );
  
  public Collection<RequestBean> selectRequestsByLeadExecutor(
    int leadExecutorId
  );
  public Collection<RequestBean> selectRequestsByLeadExecutor(
    int leadExecutorId,
    String orderBy,
    String orer
  );
  public Collection<RequestBean> selectRequestsByLeadExecutor(
    int leadExecutorId,
    String orderBy,
    String order,
    String status
  );  
  public Collection<RequestBean> selectRequestsByLeadExecutor(
    int leadExecutorId,
    String orderBy,
    String order,
    String status,
    int page,
    int itemsPerPage,
    IntWrapper records
  );
    
  public Collection<RequestHistoryBean> getRequestHistory(int requestId);
  
  public Collection<RequestStatusBean> selectRequestStatuses();
  public RequestStatusBean selectRequestStatus(int requestId);
  
  public Collection<Integer> passivateTasks(int requestId, int userId); 
  public Collection<Integer> activateTasks(int requestId, int userId);
  public boolean isAllTasksCompleated(int requestId);
  public Collection<RequestPriorityBean> selectPriorityList();
  
  public boolean cancelRequestByDispatcher(
    RequestBean requestBean,
    int dispatcherId
  );
  
  public boolean cancelRequestByLeadExecutor (
     String comment,
     int userId,
     int requestId 
  );
  
  public ReportBean selectReport(
    java.util.Date startDate, 
    java.util.Date endDate
  );
  
  //Search requests by client
  public Collection<RequestBean> searchRequestsByClient(
     RequestBean patternBean,
     String orderBy,
     String order,
     int page,
     int itemsPerPage,
     IntWrapper records,
     int clientId
   );
  
//Search requests generic
  public Collection<RequestBean> searchRequests(
     RequestBean patternBean,
     String orderBy,
     String order,
     int page,
     int itemsPerPage,
     IntWrapper records
   );
  
  public Collection<TaskBean> searchTasksByExecutor(
     TaskBean patternBean,
     String orderBy,
     String order,
     int page,
     int itemsPerPage,
     IntWrapper records
  );
  
  public Collection<MainReportBean> getMainReport(
     Date startDate, 
     Date endDate
  );
}